

interface RequestOptions {
    url: string;
    method?: string;
    headers?: HeadersInit;
    body?: BodyInit;
}

export function request(ops: RequestOptions) : Promise<any> {
    return new Promise((resolve, reject) => {
        fetch("/api" + ops.url).then((resp) => {
            return resp.json()
        }).then(data => {
            resolve(data)
        })
    })
}